import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

import static java.lang.Thread.MAX_PRIORITY;





public class ThreadPoolDemo1 {
    public static void main(String[] args) {
        ThreadFactory factory=new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                Thread thread=new Thread(r);
                thread.setName("我的线程:"+r.hashCode());
                thread.setPriority(MAX_PRIORITY);
                return thread;
            }
        };

        ExecutorService service=Executors.newFixedThreadPool(5,factory);
        for (int i = 0; i < 5; i++) {
            service.submit(()->{
                Thread thread=Thread.currentThread();
                System.out.println("线程池开始执行:"+thread.getName()+"线程池的优先级:"+thread.getPriority());
            });
        }

    }
}
